package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author zdq
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private IFollowService iFollowService;

    @PutMapping("/{followId}/{isFollow}")
    public Result follow(@PathVariable Long followId, @PathVariable Boolean isFollow) {
        if (iFollowService.follow(followId, isFollow)) {
            return Result.ok("关注成功");
        } else {
            return Result.fail("关注失败");
        }
    }

    @GetMapping("/or/not/{followId}")
    public Result follow(@PathVariable Long followId) {
        return iFollowService.getIsFollow(followId);
    }

    @GetMapping("/common/{id}")
    public Result commonFollow(@PathVariable Long id) {
        return iFollowService.commonFollow(id);
    }
}
